import { createPinia } from 'pinia';
import { createPersistedState } from 'pinia-plugin-persistedstate';

const pinia = createPinia();

// 持久化插件
pinia.use(
  createPersistedState({
    storage: {
      getItem: (key: string) => uni.getStorageSync(key),
      setItem: (key: string, value: string) => uni.setStorageSync(key, value),
    },
  })
);

export default pinia;

// 导出 store
export { useUserStore } from './modules/user';
export { useCartStore } from './modules/cart';
export { useOrderStore } from './modules/order';